/*
 * ScorePaneel.java
 *
 * Created on December 5, 2008, 4:10 PM
 */

package tetris.view;

import java.awt.FlowLayout;
import java.util.Observable;
import java.util.Observer;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.Box;
import javax.swing.BoxLayout;
import tetris.model.blokken.Bord;
import tetris.model.spel.KnoppenPaneel;
import tetris.model.spel.Score;
import tetris.model.spel.SpeelTijd;
import tetris.model.spel.VolgendBlok;

/**
 *
 * @author  Batist Leman & Pieter Hens
 */
public class ScorePaneel extends javax.swing.JPanel implements Observer {
       private Bord bord;
    private VolgendBlok volgendblokje;
    private Score score;
    private  KnoppenPaneel knoppen;
    private HoofdPaneel hoofdframe;
    
    /** Creates new form ScorePaneel */
    public ScorePaneel() {
        initComponents();
        //setLayout(new FlowLayout());
        //add(new JLabel("bla"));
        
        volgendblokje = new VolgendBlok();
        add(volgendblokje);
        SpeelTijd klok = new SpeelTijd(this);
             add(klok);
         score = new Score();
         add( score);
         knoppen = new KnoppenPaneel(klok);
         
         add(knoppen);
        
       
        
         
        
    }
    
    public void setBord (Bord b) {
                bord = b; 
        knoppen.setBord(bord);
        score.setBord(bord);
        //System.out.println("bord is gezet");
    }

    
     void setHoofdframe(HoofdPaneel hfdframe) {
        hoofdframe = hfdframe;
        knoppen.setHoofdpaneel(hoofdframe);
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 398, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 298, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents

    public void update(Observable o, Object arg) {
                try {
            if (arg != null) {
              Thread.sleep(100);  
            }

        volgendblokje.setBlok(bord.getVolgendBlok());
        score.setAantalLijnen(bord.getAantallijnen());
        
        } catch (InterruptedException ex) {
            Logger.getLogger(BordPaneel.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    



    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables

    
    
}
